const hre = require("hardhat");
const utils = require("./utils");
module.exports = {
    
    //部署工厂合约
    async factory(signers) {
        const Factory = await hre.ethers.getContractFactory("ChaingeDexFactory");
        const factoryContract = await Factory.deploy(signers.address);
        await factoryContract.deployed();
        await utils.sleep()
        console.log('部署的工厂合约地址:',factoryContract.address);
        return factoryContract;
    },

    //创建交易对
   async createPair(factory, tokenA, tokenB, config) {
        const pair = await factory.createPair(tokenA.address, tokenB.address, [config.startTime, config.endTime, config.startTime, config.endTime]); // 创建个1617212453 到永远的和 1627212453 到永远的。
        const pairAddress = await factory.getPair(tokenA.address, tokenB.address, [config.startTime, config.endTime, config.startTime, config.endTime]);
        console.log('创建的交易对地址:',pairAddress);
        return pairAddress;
    }
    
};
  